package com.xinghou.platform.server.api.controller;

import com.xinghou.platform.entity.req.ReportErrorReq;
import com.xinghou.platform.entity.resp.ReportErrorResp;
import com.xinghou.platform.server.api.bussiness.ReportErrorInfoBusinessService;
import com.xinghou.platform.util.ConfigUtil;
import com.xinghou.platform.util.StringUtils;
import com.xinghou.platform.util.exception.DBExceptionEnums;
import com.xinghou.platform.util.exception.ServiceException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@Controller
public class ReportErrorInfoController extends BaseControl {
	private String key = ConfigUtil.getProperty("HTTP_SERVICE_KEY");
/*
	private String reqjson;//请求json
	private String repjson;//返回json
	
	private ReportErrorResp reportErrorResp;
	private List<ReportErrorInfo> reportErrorInfoList = new ArrayList<ReportErrorInfo>();*/
	
	@Resource
	private ReportErrorInfoBusinessService 	reportErrorInfoBusinessService;
	
	private boolean bool = false;

	/**
	 * 举报、报错列表新建
	 * @return
	 */
	@ResponseBody
	@SuppressWarnings("unchecked")
	@RequestMapping(value = "/createError", method = {RequestMethod.POST,RequestMethod.GET})
	public String  createError(
			@RequestBody ReportErrorReq reportErrorReq,
			HttpServletRequest request, HttpServletResponse response){
		ReportErrorResp	reportErrorResp = new ReportErrorResp();

			if(StringUtils.isBlank(reportErrorReq.getUserid())){
				throw new ServiceException(DBExceptionEnums.USER_IS_NULL);
			}else if(StringUtils.isBlank(reportErrorReq.getToid())){
				throw new ServiceException(DBExceptionEnums.TO_USERID_IS_NULL);
			}else if(StringUtils.isBlank(reportErrorReq.getType())){
				throw new ServiceException(DBExceptionEnums.TYPE_IS_NULL);
			}
			
				int n = reportErrorInfoBusinessService.saveReportError(reportErrorReq);
		return response(reportErrorResp);
	}
	/*
	public String getReqjson() {
		return reqjson;
	}
	
	public void setReqjson(String reqjson) {
		this.reqjson = reqjson;
	}
	
	public String getRepjson() {
		return repjson;
	}
	
	public void setRepjson(String repjson) {
		this.repjson = repjson;
	}
	
	public String getKey() {
		return key;
	}
	
	public void setKey(String key) {
		this.key = key;
	}
	


	public ReportErrorResp getReportErrorResp() {
		return reportErrorResp;
	}

	public void setReportErrorResp(ReportErrorResp reportErrorResp) {
		this.reportErrorResp = reportErrorResp;
	}

	public List<ReportErrorInfo> getReportErrorInfoList() {
		return reportErrorInfoList;
	}

	public void setReportErrorInfoList(List<ReportErrorInfo> reportErrorInfoList) {
		this.reportErrorInfoList = reportErrorInfoList;
	}
*/

}
